
var pattern = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&]).{8,20}$/;

function modifyPassword(){
    if (!document.getElementById("newPass").value) {
        $.messager.alert('提示', '密码不能为空!');
        return;
    }
    if (!document.getElementById("surePass").value) {
        $.messager.alert('提示', '确认密码不能为空!');
        return;
    }
    var pass = $("#newPass").val();
    var surePass = $("#surePass").val();
    if(pass != surePass){
        $.messager.alert('提示', '密码输入不一致!');
        return;
    }
    if(!pattern.test(pass)){
        $.messager.alert('提示', '密码格式不合法'+pass);
        return;
    }
    $.ajax({ url: '/personalCenter/modify.do', data: { newPass: pass }, type: 'POST', dataType: 'text',
        success: function (fn) {
            alert('密码修改成功！');
        },
        error: function (xhr) {
            alert('修改失败！');
        }
    });
}

function modify(){

    var id = $("#id").val();
    var code = $("#code").val();
    var name = $("#name").val();
    var sname = $("#sname").val();
    var type = $("#type").val();
    var level = $("#level").val();
    var pid = $("#pid").val();
    var area = $("#area").val();
    var charge = $("#charge").val();
    var phone = $("#phone").val();
    var author = $("#author").val();
    var email = $("#email").val();
    var address = $("#address").val();

    $.ajax({ url: '/department/save.do', data: { id: id, code:code,name:name,sname:sname,type:type,level:level,pid:pid,
    area:area,charge:charge,phone:phone,author:author,email:email,address:address}, type: 'POST', dataType: 'text',
        success: function (fn) {
            alert('修改成功！');
        },
        error: function (xhr) {
            alert('修改失败！');
        }
    });
}

function resetPass(){
    $("#newPass").attr("value","");
    $("#surePass").attr("value","");
}